//
//  MoreBuildsTCell.m
//  PgyHelper
//
//  Created by 鹏鹏 on 2021/1/6.
//  Copyright © 2021 CleverPeng. All rights reserved.
//

#import "MoreBuildsTCell.h"
#import "RequestTool.h"
#import "PPTools.h"

@interface MoreBuildsTCell()

@property (weak, nonatomic) IBOutlet UIImageView *buildIconImageView;
@property (weak, nonatomic) IBOutlet UILabel *buildNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *buildVersionLabel;
@property (weak, nonatomic) IBOutlet UILabel *buildBuildVersionLabel;
@property (weak, nonatomic) IBOutlet UILabel *buildVersionNoLabel;
@property (weak, nonatomic) IBOutlet UIView *descBGView;
@property (weak, nonatomic) IBOutlet UILabel *buildDescLabel;
@property (weak, nonatomic) IBOutlet UILabel *buildSizeLabel;
@property (weak, nonatomic) IBOutlet UILabel *buildCreatedLabel;
@property (weak, nonatomic) IBOutlet UIImageView *seleIMGV;

@end

@implementation MoreBuildsTCell

- (void)awakeFromNib {
    [super awakeFromNib];

    self.buildIconImageView.layer.cornerRadius = 8;
    self.buildIconImageView.layer.masksToBounds = YES;

    self.descBGView.layer.cornerRadius = 4;
    self.descBGView.layer.masksToBounds = YES;

    self.seleIMGV.hidden = YES;
}

- (void)setIsEditingStatus:(BOOL)isEditingStatus {
    _isEditingStatus = isEditingStatus;
    self.seleIMGV.hidden = !isEditingStatus;
}

- (void)setBuildsModel:(MoreBuildsModel *)buildsModel {
    _buildsModel = buildsModel;


    self.seleIMGV.image = buildsModel.isSelected ? [UIImage systemImageNamed:@"checkmark.circle.fill"] : [UIImage systemImageNamed:@"circle"];

    NSString *iconUrl = HOST_URL_app_icons(buildsModel.buildIcon);
    [self.buildIconImageView sd_setImageWithURL:[NSURL URLWithString:iconUrl] placeholderImage:[UIImage imageNamed:@"app_icon"]];
    self.buildNameLabel.text = buildsModel.buildName;
    self.buildVersionLabel.text = [NSString stringWithFormat:@"V%@", buildsModel.buildVersion];
    self.buildBuildVersionLabel.text = [NSString stringWithFormat:@"(%@)", buildsModel.buildBuildVersion];
    self.buildVersionNoLabel.text = [NSString stringWithFormat:@"Xcode build: %@", buildsModel.buildVersionNo];
    self.buildDescLabel.text = [NSString stringWithFormat:@"%@", buildsModel.buildUpdateDescription];
    self.buildSizeLabel.text = [NSString stringWithFormat:@"大小: %@", [PPTools fileSizeFormat:[buildsModel.buildFileSize longLongValue]]];
    self.buildCreatedLabel.text = [NSString stringWithFormat:@"上传时间: %@", buildsModel.buildCreated];
}

@end
